package com.cnswhy.cloud.server.system.controller;

import com.cnswhy.cloud.server.system.entity.LoginLog;
import com.cnswhy.cloud.server.system.dto.LoginLogSaveDTO;
import com.cnswhy.cloud.server.system.dto.LoginLogUpdateDTO;
import com.cnswhy.cloud.server.system.dto.LoginLogPageDTO;
import com.cnswhy.cloud.server.system.service.LoginLogService;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.cnswhy.cloud.common.core.base.controller.SuperController;
import com.cnswhy.cloud.common.core.base.R;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
//import com.github.zuihou.security.annotation.PreAuth;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 登录日志表
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-09
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/loginLog")
@Api(value = "LoginLog", tags = "登录日志表")
//@PreAuth(replace = "loginLog:")
public class LoginLogController extends SuperController<LoginLogService, Long, LoginLog, LoginLogPageDTO, LoginLogSaveDTO, LoginLogUpdateDTO> {

    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<LoginLog> loginLogList = list.stream().map((map) -> {
            LoginLog loginLog = LoginLog.builder().build();
            //TODO 请在这里完成转换
            return loginLog;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(loginLogList));
    }
}
